#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "ControlNode.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class ValueSpecification;

/// <summary>
/// JoinNode
/// A JoinNode is a ControlNode that synchronizes multiple flows.
/// </summary>
class UMLMODEL_EXPORT JoinNode : public ControlNode {

public: // Constructors and destructors
    explicit JoinNode(const QString& umlType="uml::JoinNode");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// isCombineDuplicate getter
    /// Indicates whether incoming tokens having objects with the same identity are
    /// combined into one by the JoinNode.
    /// </summary>
    bool isCombineDuplicate() const;

    /// <summary>
    /// isCombineDuplicate setter
    /// Indicates whether incoming tokens having objects with the same identity are
    /// combined into one by the JoinNode.
    /// </summary>
    void setIsCombineDuplicate(bool value);

    /// <summary>
    /// joinSpec getter
    /// A ValueSpecification giving the condition under which the JoinNode will offer a
    /// token on its outgoing ActivityEdge. If no joinSpec is specified, then the
    /// JoinNode will offer an outgoing token if tokens are offered on all of its
    /// incoming ActivityEdges (an "and" condition).
    /// </summary>
    shared_ptr<ValueSpecification> joinSpec() const;

    /// <summary>
    /// joinSpec setter
    /// A ValueSpecification giving the condition under which the JoinNode will offer a
    /// token on its outgoing ActivityEdge. If no joinSpec is specified, then the
    /// JoinNode will offer an outgoing token if tokens are offered on all of its
    /// incoming ActivityEdges (an "and" condition).
    /// </summary>
    void setJoinSpec(shared_ptr<ValueSpecification> value);

private: // Fields
    /// <summary>
    /// isCombineDuplicate
    /// Indicates whether incoming tokens having objects with the same identity are
    /// combined into one by the JoinNode.
    /// </summary>
    const static bool isCombineDuplicate_default_;
    bool isCombineDuplicate_= isCombineDuplicate_default_;

    /// <summary>
    /// joinSpec
    /// A ValueSpecification giving the condition under which the JoinNode will offer a
    /// token on its outgoing ActivityEdge. If no joinSpec is specified, then the
    /// JoinNode will offer an outgoing token if tokens are offered on all of its
    /// incoming ActivityEdges (an "and" condition).
    /// </summary>
    shared_ptr<ValueSpecification> joinSpec_;

};

} // namespace uml
